/*
 *      screen.hpp
 *
 *      Copyright 2007 Marcelo Araujo <<araujo@FreeBSD.org>>
 *
 *      Copyright (c) 2007 Marcelo S. Araujo
 *      All rights reserved.
 *
 *      Redistribution and use in source and binary forms, with or without
 *      modification, are permitted provided that the following conditions are
 *      met:
 *
 *      * Redistributions of source code must retain the above copyright
 *        notice, this list of conditions and the following disclaimer.
 *      * Redistributions in binary form must reproduce the above
 *        copyright notice, this list of conditions and the following disclaimer
 *        in the documentation and/or other materials provided with the
 *        distribution.
 *      * Neither the name of the Intelbras nor the names of its
 *        contributors may be used to endorse or promote products derived from
 *        this software without specific prior written permission.
 *
 *      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *      "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *      LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 *      A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 *      OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 *      SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 *      LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *      DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *      THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *      (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 *      OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *
 */

#include <iostream>

using namespace std;

class Screen {
	public:
	void Screen_Header(void);
	void Screen_Header_Codec(void);
	void Screen_Head_Users(void);
	void Screen_Division(void);
};

void Screen::Screen_Header(void) {
	system("clear");
	cout << "         Disc-OS - Calculador de Bandwith         " << endl;
	cout << "         --------------------------------\n\n";
}
void Screen::Screen_Header_Codec(void) {
	cout << "+-----[ CODEC ]---------------[  Bandwith  ]-----+" << endl;
}

void Screen::Screen_Head_Users(void) {
	cout << "+-----[ CODEC ]---------------[    User    ]-----+" << endl;
}

void Screen::Screen_Division(void) {
	cout << "|------------------------------------------------|" << endl;
}

class Menu {
	public:
	int Screen_Menu(void);
};

int Menu::Screen_Menu(void) {
		int option;
		Screen screen;
		system("clear");
		screen.Screen_Header();
		cout << "1) Banda por numero de usuario." << endl;
		cout << "2) Numero de usuario por banda." << endl;
		cout << "\n" << "Menu: ";
		cin >> option;

		return option;
}

class Menu_Option {
	public:
	void U_Calc(int i);
};

void Menu_Option::U_Calc(int i) {
	Codecs codecs;
	Users users;
	Screen screen;
	const string Codec_Name[100] = {"", "G711", "G729", "G723", "G726-32", "GSM", "iLBC", "SPEEX"};
	float result;
	int users_count;
	if(i == 1)
	{
		cout << "Numero de usuarios: ";
		cin >> users_count;
		screen.Screen_Header();
		screen.Screen_Header_Codec();
		for(register int i = 1; i<7; i++)
		{
			result = codecs.Bandwith_Codecs(i);
			result = codecs.Bandwith_Calc(result, users_count);
			cout << "|\t" << Codec_Name[i] << "\t\t\t" << result << " Kbps" << "\t |" << endl;
			screen.Screen_Division();
		}
		cout << "Numero de usuarios: " << users_count << endl;
	}
	if(i == 2)
	{
		float bandwith_Kbps;
		float result_u;
		cout << "Banda disponivel em Kbps: ";
		cin >> bandwith_Kbps;
		screen.Screen_Header();
		screen.Screen_Head_Users();
		for(register int i = 1; i<7; i++)
		{
			result_u = codecs.Bandwith_Codecs(i);
			result_u = users.Users_Calc(bandwith_Kbps, result_u);
			cout << "|\t" << Codec_Name[i] << "\t\t\t" << result_u << " Users" << "\t |" << endl;
			screen.Screen_Division();
		}
		cout << "Banda estipulada em Kbps: " << bandwith_Kbps << endl;
	}
};

